﻿using Microsoft.EntityFrameworkCore;
using QModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QServices.Services
{
	public partial class PigeonChildService:QMainService
	{
		public List<PigeonChild> GetPigeonChildList()
		{
			 var db=CreateDbContext();
			var res=db.Set<PigeonChild>().ToList();
			return res;
		}

		public List<PigeonChild> GetPigeonChildListByArea( string areaname)
		{
			using var db=CreateDbContext();
			
			var sql = @"
				select child.* from PigeonChild  child
LEFT JOIN  PigeonCage cage on child.PigeonHouseID = cage.ID
where cage.Building is NOT NULL
				";
			if (!string.IsNullOrWhiteSpace(areaname))
			{
				sql += $"  and  cage.Building='{areaname}'";
			}
			var res=db.Database.SqlQueryRaw<PigeonChild>(sql).ToList();
			return res;
		}


	



	}
}
